﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>$CreationDate$</CreationDate>
</File>
*/
#endregion
using System;

namespace Outcoder.Drawing
{
	public static class ScalingTool
	{
		public static void ScaleAndConstrainProportions(
			double originalWidth, double originalHeight,
			double maxWidth, double maxHeight,
			out double scaledWidth, out double scaledHeight)
		{
			double ratioX = maxWidth / originalWidth;
			double ratioY = maxHeight / originalHeight;
			double ratio = Math.Min(ratioX, ratioY);

			scaledWidth = originalWidth * ratio;
			scaledHeight = originalHeight * ratio;
		}
	}
}
